package com.junsi.service.impl;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.junsi.bean.Client;
import com.junsi.mapper.ClientMapper;
import com.junsi.service.ClientService;

/**   
  * @文件名: ClientServiceImpl.java 
  * @包名: com.junsi.service.impl 
  * @类名: ClientServiceImpl   
  * @时间: 2017年7月19日 上午9:07:31 2017
  * @作者: 
  * @类功能描述:TODO 请简要描述你的类   
  */
@Service
@Transactional(rollbackFor = Exception.class)
public class ClientServiceImpl implements ClientService {
	
	@Autowired
	private ClientMapper clientMapper;

	@Override
	/**
	 * 查询所有
	 */
	public List<Client> findByAll() {
		List<Client> list = clientMapper.findByAll();
		return list;
	}

	@Override
	/**
	 * 根据id查询
	 */
	public Client findById(Integer id) {
		Client client = clientMapper.findById(id);
		return client;
	}

	@Override
	/**
	 * 根据id删除
	 */
	public boolean deleteById(Integer id) {
		int i = clientMapper.deleteById(id);
		if(i == 1){
			return true;
		}
		return false;
	}

	@Override
	/**
	 * 新增
	 */
	public boolean save(Client client) {
		int i = clientMapper.save(client);
		if(i == 1){
			return true;
		}
		return false;
	}

	@Override
	/**
	 * 修改
	 */
	public boolean update(Client client) {
		int i = clientMapper.update(client);
		if(i == 1){
			return true;
		}
		return false;
	}

	@Override
	/**
	 * 分页查询
	 */
	public List<Client> findByPage(Integer id, Integer endIndex, Integer startIndex) {
		if(endIndex == null){
			return null;
		}
		if(startIndex == null){
			return null;
		}		
		return clientMapper.findByPage(id, endIndex, startIndex);
	}

	@Override
	/**
	 * 查询有多少条记录数
	 */
	public Integer findByNumber() {
		return clientMapper.findByNumber();
	}
	
	/*@Override
	public List<Client> findByStaffId(Integer staff_id) {
		
		return clientMapper.findByStaffId(staff_id);
	}*/

	@Override
	public List<Client> findByAlls(String[] id) {
		
		return clientMapper.findByAlls(id);
	}

	@Override
	public List<Client> findByClientName(String client_name) {
		
		return clientMapper.findByClientName(client_name);
	}



	@Override
	public List<Integer> findByAllForId(String[] id) {
		
		return clientMapper.findByAllForId(id);
	}

	@Override
	public boolean deleteByIds(String[] id) {
		int i = clientMapper.deleteByIds(id);
		if(i != 0){
			return true;
		}
		
		return false;
	}

	@Override
	public List<Client> findByDepartmentOrStaffIdAndSelect(Integer depId, String[] staff_id, String select) {
		
		select = "%"+select+"%";
		
		return clientMapper.findByDepartmentOrStaffIdAndSelect(depId, staff_id, select);
	}
	

	@Override
	public List<Client> findByAllForAgentOne(Integer endIndex,Integer beforIndex,String select,String state) {
		
		if(select != null && !"".equals(select)) {
			select = "%"+select+"%";
		}else {
			select = null;
		}
		
		return clientMapper.findByAllForAgentOne(endIndex,beforIndex,select,state);
	}

	@Override
	public List<Client> findByAllForAgentTwo(Integer endIndex,Integer beforIndex) {
		
		return clientMapper.findByAllForAgentTwo(endIndex,beforIndex);
	}

	@Override
	public boolean updateByAgent(Integer[] client_id, Integer staff_id, Integer depId,String remarks) {
		int i = clientMapper.updateByAgent(client_id, staff_id, depId,remarks);
		if(i != 0){
			return true;
		}
		return false;
	}

	@Override
	public boolean updateByPersonal(Integer[] client_id, Integer staff_id, Integer depId) {
		int i = clientMapper.updateByPersonal(client_id, staff_id, depId);
		if(i != 0){
			return true;
		}
		return false;
	}

	@Override
	public List<Client> findByAllFroSelect(String start, String select) {
		select = "%"+select+"%";
		return clientMapper.findByAllFroSelect(start, select);
	}

	@Override
	public List<Client> findByAllFroSelectByNo(String start, String select) {
		select = "%"+select+"%";
		return clientMapper.findByAllFroSelectByNo(start, select);
	}

	@Override
	public List<Client> findByAllFroSelectByGR(String select) {
		select = "%"+select+"%";
		return clientMapper.findByAllFroSelectByGR(select);
	}

	@Override
	public Integer findByDepartmentOrStaffIdNumber(Integer depId, String[] id,String select,String state) {
		if(select != null && !"".equals(select)) {
			select = "%"+select+"%";
		}else {
			select = null;
		}
		
		return clientMapper.findByDepartmentOrStaffIdNumber(depId, id,select,state);
	}

	@Override
	public Integer findByStaffIdNumber(String[] id) {
		
		return clientMapper.findByStaffIdNumber(id);
	}

	@Override
	public List<Client> findByDepartmentOrStaffId(Integer depId, String[] staff_id, Integer endIndex,
			Integer beforIndex,String select,String state) {
		
		if(select != null && !"".equals(select)) {
			select = "%"+select+"%";
		}else {
			select = null;
		}
		
		return clientMapper.findByDepartmentOrStaffId(depId, staff_id, endIndex, beforIndex,select,state);
	}

	@Override
	public List<Client> findByStaffId(Integer staff_id) {
		
		return clientMapper.findByStaffId(staff_id);
	}

	@Override
	public Integer findByAllForAgentOneNumber(String state,String select) {
		
		if(select != null && !"".equals(select)) {
			select = "%"+select+"%";
		}else {
			select = null;
		}
		
		return clientMapper.findByAllForAgentOneNumber(state,select);
	}

	@Override
	public Integer findByAllForAgentTwoeNumber() {
		
		return clientMapper.findByAllForAgentTwoeNumber();
	}

	@Override
	public List<Client> findByAllPersonal(Integer endIndex, Integer beforIndex) {
		
		return clientMapper.findByAllPersonal(endIndex, beforIndex);
	}

	@Override
	public Integer findByAllPersonalNumber() {
		
		return clientMapper.findByAllPersonalNumber();
	}

	@Override
	public boolean updateByTo(String[] id) {
		int i = clientMapper.updateByTo(id);
		if(i != 0){
			return true;
		}
		return false;
	}

	@Override
	public List<Client> findByDepartmentOrStaffIds(Integer depId, String[] staff_id, Integer endIndex,
			Integer beforIndex) {
		
		return clientMapper.findByDepartmentOrStaffIds(depId, staff_id, endIndex, beforIndex);
	}

	@Override
	public List<Client> findByStaffIds(String[] staff_id, Integer endIndex, Integer beforIndex) {
		
		return clientMapper.findByStaffIds(staff_id, endIndex, beforIndex);
	}

	@Override
	public Integer findByDepartmentOrStaffIdNumbers(Integer depId, String[] id) {
		
		return clientMapper.findByDepartmentOrStaffIdNumbers(depId, id);
	}

	@Override
	public Integer findByStaffIdNumbers(String[] id) {
		
		return clientMapper.findByStaffIdNumbers(id);
	}

	@Override
	public List<Client> findByAllPersonals(Integer endIndex, Integer beforIndex) {
		
		return clientMapper.findByAllPersonals(endIndex, beforIndex);
	}
	
	@Override
	public Integer findByAllPersonalNumbers() {
		
		return clientMapper.findByAllPersonalNumbers();
	}

	@Override
	public Integer findByAllAgentDataNumber() {
		
		return clientMapper.findByAllAgentDataNumber();
	}

	@Override
	public List<Client> findByAllAgentData(Integer endIndex, Integer beforIndex) {
		
		return clientMapper.findByAllAgentData(endIndex, beforIndex);
	}

	@Override
	public List<Client> findByAllFroSelectData(String start, String select) {
		
		return clientMapper.findByAllFroSelectData(start, select);
	}

	@Override
	public List<Client> findByAllFroSelectByGRData(String select) {
		
		return clientMapper.findByAllFroSelectByGRData(select);
	}

	@Override
	public List<Client> findByDepartmentOrStaffIdAndSelects(Integer depId, String[] staff_id, String select) {
		
		return clientMapper.findByDepartmentOrStaffIdAndSelects(depId, staff_id, select);
	}

	@Override
	public List<Client> findByStaffIdAndSelects(String[] staff_id, String select) {
		
		return clientMapper.findByStaffIdAndSelects(staff_id, select);
	}

	@Override
	public List<Client> findAllPersonals() {
		 List<Client> list=clientMapper.findAllPersonals();
		return list;
	}

	@Override
	public List<Client> findAllAgentData() {
		 List<Client> list=clientMapper.findAllAgentData();
			return list;
	}

	@Override
	public List<Client> findAllPersonal() {
		 List<Client> list=clientMapper.findAllPersonal();
			return list;
	}

	@Override
	public List<Client> findAllForAgentOne() {
		 List<Client> list=clientMapper.findAllForAgentOne();
			return list;
	}

	@Override
	public List<Client> findByAllPersonalweifen(Integer endIndex, Integer beforIndex) {
		// TODO Auto-generated method stub
		return clientMapper.findByAllPersonalweifen(endIndex, beforIndex);
	}

	@Override
	public Integer findByAllPersonalNumberweifen() {
		// TODO Auto-generated method stub
		return clientMapper.findByAllPersonalNumberweifen();
	}



	@Override
	public List<Client> findByAllPersonalyifen(Integer endIndex, Integer beforIndex) {
		// TODO Auto-generated method stub
		return clientMapper.findByAllPersonalyifen(endIndex, beforIndex);
	}

	@Override
	public Integer findByAllPersonalNumberyifen() {
		// TODO Auto-generated method stub
		return clientMapper.findByAllPersonalNumberyifen();
	}

	@Override
	public List<Client> findByAllFroSelectByyifen(String select) {
		select="%"+select+"%";
		return clientMapper.findByAllFroSelectByyifen(select);
	}

	@Override
	public List<Client> findByAllFroSelectByGRDataweifen(String select, Integer endIndex, Integer beforIndex) {
		select="%"+select+"%";
		return clientMapper.findByAllFroSelectByGRDataweifen(select, endIndex, beforIndex);
	}

	@Override
	public Integer findByAllFroSelectByGRDataweifenzongshu(String select) {
		select="%"+select+"%";
		return clientMapper.findByAllFroSelectByGRDataweifenzongshu(select);
	}

	@Override
	public List<Client> findAllyifenPersonal() {
		// TODO Auto-generated method stub
		return clientMapper.findAllyifenPersonal();
	}

	@Override
	public List<Client> findAllweifenPersonal() {
		// TODO Auto-generated method stub
		return clientMapper.findAllweifenPersonal();
	}

	@Override
	public List<Client> findByAllPersonalgengzong(Integer endIndex, Integer beforIndex) {
		// TODO Auto-generated method stub
		return clientMapper.findByAllPersonalgengzong(endIndex, beforIndex);
	}

	@Override
	public Integer findByAllPersonalNumbergenzong() {
		// TODO Auto-generated method stub
		return clientMapper.findByAllPersonalNumbergenzong();
	}

	@Override
	public List<Client> findAllyifenPersonalgenzong() {
		// TODO Auto-generated method stub
		return clientMapper.findAllyifenPersonalgenzong();
	}

	@Override
	public List<Client> findByAllFroSelectByGRDatagenzong(String select, Integer endIndex, Integer beforIndex) {
		select="%"+select+"%";
		return clientMapper.findByAllFroSelectByGRDatagenzong(select, endIndex, beforIndex);
	}

	@Override
	public Integer findByAllFroSelectByGRDatagenzhongshu(String select) {
		select="%"+select+"%";
		return clientMapper.findByAllFroSelectByGRDatagenzhongshu(select);
	}

	

	@Override
	public Integer findByStaffIdNumberkaifa(String[] id) {
		return clientMapper.findByStaffIdNumberkaifa(id);
	}

	@Override
	public List<Client> findByStaffIdkaifa(String[] staff_id, Integer endIndex, Integer beforIndex) {
		return clientMapper.findByStaffIdkaifa(staff_id, endIndex, beforIndex);
	}


	@Override
	public Integer findByStaffIdAndSelectyikaifazongshu(String[] id,String select) {
		select = "%"+select+"%";
		Integer cou=clientMapper.findByStaffIdAndSelectyikaifazongshu(id, select);
		return cou;
	}

	@Override
	public Integer findByStaffIdAndSelectgengzongzongshu(String[] id,String select) {
		select = "%"+select+"%";
		return clientMapper.findByStaffIdAndSelectgengzongzongshu(id, select);
	}

	@Override
	public List<Client> findByStaffIdAndSelectkaifa(String[] staff_id, String select, Integer endIndex,
			Integer beforIndex) {
		select = "%"+select+"%";
		return clientMapper.findByStaffIdAndSelectkaifa(staff_id, select, endIndex, beforIndex);
	}

	@Override
	public List<Client> findByStaffIdAndSelect(String[] staff_id, String select, Integer endIndex, Integer beforIndex) {
		select = "%"+select+"%";
		return clientMapper.findByStaffIdAndSelect(staff_id, select, endIndex, beforIndex);
	}

	@Override
	public List<Client> findByStaffIdqiangenzong(String[] staff_id, Integer endIndex, Integer beforIndex) {
		return clientMapper.findByStaffIdqiangenzong(staff_id, endIndex, beforIndex);
	}

	@Override
	public List<Client> findByAllPersonalhuishou(Integer endIndex, Integer beforIndex) {
		return clientMapper.findByAllPersonalhuishou(endIndex, beforIndex);
	}

	@Override
	public Integer findByAllPersonalNumberyihuishou() {
		return clientMapper.findByAllPersonalNumberyihuishou();
	}

	@Override
	public Integer findByAllFroSelectByGRDatakaifashu(String select) {
		select = "%"+select+"%";
		return clientMapper.findByAllFroSelectByGRDatakaifashu(select);
	}

	@Override
	public Integer findByAllFroSelectByGRDatahuishoushu(String select) {
		select = "%"+select+"%";
		return clientMapper.findByAllFroSelectByGRDatahuishoushu(select);
	}

	@Override
	public List<Client> findByAllFroSelectByGRDatachayikaifa(String select, Integer endIndex, Integer beforIndex) {
		select = "%"+select+"%";
		return clientMapper.findByAllFroSelectByGRDatachayikaifa(select, endIndex, beforIndex);
	}

	@Override
	public List<Client> findByAllFroSelectByGRDatachayihuishou(String select, Integer endIndex, Integer beforIndex) {
		select = "%"+select+"%";
		return clientMapper.findByAllFroSelectByGRDatachayihuishou(select, endIndex, beforIndex);
	}

	@Override
	public List<Client> findAllyifenPersonalhuishoua() {
		// TODO Auto-generated method stub
		return clientMapper.findAllyifenPersonalhuishoua();
	}

	
}
